package com.geek.novel.utils

import android.content.res.ColorStateList
import android.graphics.Color
import androidx.appcompat.widget.SwitchCompat
import androidx.core.graphics.drawable.DrawableCompat

/**UI相关的工具*/
object UiUtils {

    fun setSwitchColor(v: SwitchCompat, thumbColor: Int, thumbColorGrey: Int) {
        v.background = null
        // set the thumb color
        DrawableCompat.setTintList(
            v.thumbDrawable, ColorStateList(
                arrayOf(intArrayOf(android.R.attr.state_checked), intArrayOf()), intArrayOf(
                    thumbColor,
                    0xfff1f1f1.toInt()
                )
            )
        )
        // set the track color
        DrawableCompat.setTintList(
            v.trackDrawable, ColorStateList(
                arrayOf(intArrayOf(android.R.attr.state_checked), intArrayOf()), intArrayOf(
                    thumbColorGrey,
                    0x4d2f2f2f
                )
            )
        )
    }

}